***********************************************
* Table 1 - VILLAGE
***********************************************

*----------------------------------------------
* CROSS-SECTIONAL MODELS
*----------------------------------------------
* load the data
use village-cross-sectional.dta, clear

*drop villages with no diffusion information
drop if village==10
drop if village==28
drop if village==37
drop if village==41
drop if village==66
drop if village==77

* set list of control variables
global controlsx savings shgparticipate fracGM_survey numHH fractionLeaders 

label variable mf "Microfinance uptake"
label variable diffusion_centrality_leader "Diffusion centrality"
label variable communication_centrality_leader "Communication centrality"

sum hh_lend
egen s_hh_lend = std(hh_lend)

label variable s_hh_lend "Leader households that lent money"

* COMMUNICATION CENTRALITY
* estimate the cross-sectional models with communication centrality
eststo m1: reg mf communication_centrality_leader $controlsx, robust 
eststo m2: reg mf communication_centrality_leader s_hh_lend $controlsx, robust
* output the results with SEs
esttab m1 m2, se nostar label replace drop($controlsx)

* DIFFUSION CENTRALITY
eststo m3: reg mf diffusion_centrality_leader $controlsx, robust
eststo m4: reg mf diffusion_centrality_leader s_hh_lend $controlsx, robust
esttab m3 m4, se nostar label replace drop($controlsx)

*----------------------------------------------
* PANEL MODELS
*----------------------------------------------
* load the data
use village-panel.dta, clear

*drop villages with no diffusion information
drop if village==10
drop if village==28
drop if village==37
drop if village==41
drop if village==66
drop if village==77

* set list of control variables
global controlsx savings shgparticipate fracGM_survey numHH fractionLeaders 

sum hh_lend
egen s_hh_lend = std(hh_lend)

label variable s_hh_lend "Leader households that lent money"
label variable diffusion_centrality_leader "Diffusion centrality"
label variable communication_centrality_leader "Communication centrality"

* COMMUNICATION CENTRALITY
eststo m7: reg dynamicMF_empirical communication_centrality_leader s_hh_lend t i.t $controlsx, robust 

* DIFFUSION CENTRALITY
eststo m8: reg dynamicMF_empirical diffusion_centrality_leader s_hh_lend t i.t $controlsx, robust 
esttab m7 m8, se nostar label replace drop($controlsx)

*******************************************************
* OUTPUT RESULTS
*******************************************************
esttab m1 m2 m7 m3 m4 m8 using Table-1.rtf, se nostar label replace ///
	stats(r2 N , fmt(2 0 2 0) label(R-sq. N))  ///
	drop($controlsx ///
	0.t 1.t 2.t 3.t 4.t 5.t 6.t 7.t 8.t 9.t) ///
	order(s_hh_lend communication_centrality_leader diffusion_centrality_leader t) ///
	title(Microfinance diffusion within the village networks. OLS model estimates, robust standard errors in parentheses. All models control for savings rate, SHG participation, caste composition, number of households, and fraction of households with leaders.)
	